package com.ruoyi.user.client;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.user.api.domain.UcenterMember;
import com.ruoyi.user.api.feign.IUserClient;
import com.ruoyi.user.service.IUcenterMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Alex
 * @version 1.0
 * @date 2023/9/23 10:40
 */
@RestController
public class UserClient implements IUserClient {
    @Autowired
    private IUcenterMemberService ucenterMemberService;
    /**
     * 远程调用，order模块创建订单时向user模块获取会员信息
     *
     * @param memberId 会员id
     * @return 会员详细信息
     */
    @Override
    @RequestMapping("/user/member/{memberId}")
    public AjaxResult getMemberInfo(@PathVariable("memberId") String memberId) {
        UcenterMember byId = ucenterMemberService.getById(memberId);
        return null == byId? AjaxResult.error("会员不存在"): AjaxResult.success(byId);
    }
}
